import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import BlogDetail from '../views/BlogDetail.vue'
import BlogEdit from '../views/BlogEdit.vue'
import "../assets/css/initCss.css"
import Me from "../views/Me";
import Chat from "../views/Chat";
import Cache from '../views/cache'
import Expend from '../views/expend'

Vue.use(VueRouter)
const routes = [
    {
        path: '/',
        name: 'Index',
        redirect: {name: 'Blogs'}
    },
    {
        path: '/cache',
        name: 'Cache',
        component: Cache
    }
    ,
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/me',
        name: 'Me',
        component: Me
    },
    {
        path: '/chat',
        name: 'Chat',
        component: Chat
    }
    ,
    {
        path: '/register',
        name: 'register',
        component: () => import('../views/Register.vue') // 懒加载
    },
    {
        path: '/blogs',
        name: 'Blogs',
        // 懒加载
        component: () => import('../views/Blogs.vue')
    },
    {
        path: '/blog/add', // 注意放在 path: '/blog/:blogId'之前
        name: 'BlogAdd',
        meta: {
            requireAuth: true
        },
        component: BlogEdit
    },
    {
        path: '/blog/:blogId',
        name: 'BlogDetail',
        component: BlogDetail
    },
    {
        path: '/blog/:blogId/edit',
        name: 'BlogEdit',
        meta: {
            requireAuth: true
            // meta：requireAuth: true说明是需要登录字后才能访问的受限资源，后面我们路由权限拦截时候会用到
        },
        component: BlogEdit
    },
    {
        path: "/expend",
        name: "ExpendList",
        component: Expend
    }
];
const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})
export default router
